package dao;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Repository;

import pojo.Photo;
import pojo.User;

@Repository
public class TestDAO {

  @Autowired
  private SqlSessionTemplate template;
  
  public User selectOne1(int userID){
    User user = new User();
    user = this.template.selectOne("test.selectByID", userID);
    return user;
  }
  public User selectUser(Integer userID){
    User user = this.template.selectOne("pojo.User.selectByUserID", userID);
    return user;
  }
  public void regist(User user){
    this.template.insert("pojo.User.regist", user);
  }
  public List<Photo> selectPhotoList(Integer userID){
    return this.template.selectList("pojo.Photo.selectByUserID", userID);
  }
  public static void main(String[] args) {
    ClassPathXmlApplicationContext c = new ClassPathXmlApplicationContext("classpath:/conf/spring.xml","classpath:/conf/spring-mybatis.xml");
    TestDAO d = c.getBean(TestDAO.class);
    List<Photo> list = d.selectPhotoList(1);
    System.out.println(list);
  }
}
